import http from "@/utils/request";
import { type IRes } from "@/interFace/index";
import { type IUserInfo } from "@/interFace/user";

interface IgetUserInfo extends IUserInfo {
  data:IUserInfo
}

export const getUserInfo = ()=>{
  return http.post<IgetUserInfo>("/xlx-sso/user/getInfo")
}

// 改头像  5M内  
interface IsetUserAvatar  extends IRes{
  data:string
}
export const setUserAvatar = (file:File)=>{
  return http.post<IsetUserAvatar>('/xlx-sso/user/loginReginfo/head',file)
}

// 微信绑定  直接用 登录接口了
interface IgetLoginParam extends IRes {
  data:{
    redirectUri: string;
    appid: string;
    scope: string;
    state: string;
  }
}
// 微信扫描登录一样  就是需要传TOKEN 确定绑定的是哪个用户
export const getLoginParam =()=>{
  return http.get<IgetLoginParam>('/xlx-sso/oauth/wechat/getLoginParam')
}
//修改手机号发送验证码 
export const setModifyPhineCheckCode = (movePosX:string, phone:string)=>{
  return http.get<IRes>('/xlx-sso/user/sendModifyphoneCheckCode',{movePosX,phone})
}
interface IResWithData extends IRes {  
  data: string;  
} 
//修改手机号 
export const modifyphone = (phone:string,verificationCode:string)=>{
  return http.post<IResWithData>('/xlx-sso/user/modifyphone',{phone,verificationCode})
}

//修改密码发送验证码 这个接口用不了 405

export const modifyPasswordGetSmsCode = ()=>{
  return http.post<IResWithData>('/xlx-sso/user/sendCheckCode',)
}

//验证码验证  
export const checkSmsCodePwd = (verificationCode:string)=>{
  return http.post<IResWithData>('/xlx-sso/user/modifyPasswordVerification',{verificationCode})
}

//修改密码
export const  modifyPassword = (password:string,repassword:string)=>{
  return http.post<IResWithData>('/xlx-sso/user/modifyPassword',{password,repassword})
}

// 注销账号  405  
export const UserClear = ()=>{
  return http.get<IResWithData>('/xlx-sso/user/logout')
}